package com.bracketbird.client.gui.club.tournament.rtc;


import com.google.gwt.event.dom.client.*;
import com.bracketbird.clientcore.gui.*;
import com.bracketbird.clientcore.style.*;
import com.bracketbird.clientcore.util.*;

/**
 *
 */
public class AddTeamButton extends HorizontalComponent {
    private ImageComponent plusImg;
    private LabelComponent label;

    public AddTeamButton() {
        super();
        add(getPlusImg(), new TextLayout(0, 0, 0, 0, Vertical.MIDDLE));
        add(getLabel(), new TextLayout(4, 0, 0, 10, Vertical.MIDDLE).colorBlack().sizeH3().noWrap());
    }

    public LabelComponent getLabel() {
        if (label == null) {
            label = new LabelComponent("Add team");
            label.getLabel().addMouseOverHandler(MouseOver.POINTER);
            label.getLabel().addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    RTC.getInstance().addTeam(TeamFactory.getInstance().create(RTC.getInstance().getTournament()), true);
                }
            });

        }
        return label;
    }

    public ImageComponent getPlusImg() {
        if (plusImg == null) {
            plusImg = new ImageComponent("addteam.png");
            plusImg.getImage().addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    RTC.getInstance().addTeam(TeamFactory.getInstance().create(RTC.getInstance().getTournament()), true);
                }
            });
            plusImg.getImage().addMouseOverHandler(MouseOver.POINTER);

        }
        return plusImg;
    }



}
